home *** CD-ROM | disk | FTP | other *** search
/ PC PowerPlay 58 / pcpp58a.iso / extras / quake 3 source / Q3A_ToolSource.exe / Main / pakstuff.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-02  |  3.7 KB  |  121 lines

  1. #ifndef _PAKSTUFF_H_
  2. #define _PAKSTUFF_H_
  3.  
  4. #include <windows.h>
  5. #ifdef __cplusplus
  6. extern "C"
  7. {
  8. #endif
  9.  
  10. typedef char           Int8;
  11. typedef short          Int16;
  12. typedef long           Int32;
  13. typedef unsigned char  UInt8;
  14. typedef unsigned short UInt16;
  15. typedef unsigned long  UInt32;
  16. typedef float          Float32;
  17. typedef double         Float64;
  18. #define MAX(a, b)              (((a) > (b)) ? (a) : (b))
  19. #define MIN(a, b)              (((a) < (b)) ? (a) : (b))
  20. #define RANDOM(x)              (random() % (x))
  21. #define RANDOMIZE()             srand((int) time(NULL))
  22.  
  23. #define FTYPE_UNKNOWN 0
  24. #define FTYPE_IWAD    1    /* .wad  "IWAD" */
  25. #define FTYPE_PWAD    2    /* .wad  "PWAD" */
  26. #define FTYPE_PACK    3    /* .pak  "PACK" */
  27. #define FTYPE_WAD2    4    /* .wad  "WAD2" */
  28. #define FTYPE_BSP     10   /* .bsp  (0x17 0x00 0x00 0x00) */
  29. #define FTYPE_MODEL   11   /* .mdl  "IDPO" */
  30. #define FTYPE_SPRITE  12   /* .spr  "IDSP" */
  31. #define FTYPE_WAV     20   /* .wav  "RIFF" */
  32. #define FTYPE_AU      21   /* .au   ".snd" */
  33. #define FTYPE_VOC     22   /* .voc  ?      */
  34. #define FTYPE_PBM_ASC 30   /* .pbm  "P1"   */
  35. #define FTYPE_PGM_ASC 31   /* .pgm  "P2"   */
  36. #define FTYPE_PPM_ASC 32   /* .ppm  "P3"   */
  37. #define FTYPE_PBM_RAW 33   /* .pbm  "P4"   */
  38. #define FTYPE_PGM_RAW 34   /* .pgm  "P5"   */
  39. #define FTYPE_PPM_RAW 35   /* .ppm  "P6"   */
  40. #define FTYPE_BMP     36   /* .bmp  "BM"   */
  41. #define FTYPE_GIF     37   /* .gif  "GIF8" */
  42. #define FTYPE_PCX     38   /* .pcx  (0x0a 0x05 0x01 0x08) */
  43. #define FTYPE_ERROR   -1
  44.  
  45. #ifdef FAT_ENDIAN
  46. Bool    ReadInt16        (FILE *file, UInt16 huge *x);
  47. Bool    ReadInt32        (FILE *file, UInt32 huge *x);
  48. Bool    ReadFloat32        (FILE *file, Float32 huge *x);
  49. Bool    WriteInt16        (FILE *file, UInt16 huge *x);
  50. Bool    WriteInt32        (FILE *file, UInt32 huge *x);
  51. Bool    WriteFloat32    (FILE *file, Float32 huge *x);
  52. UInt16    SwapInt16        (UInt16 x);
  53. UInt32    SwapInt32        (UInt32 x);
  54. Float32    SwapFloat32        (Float32 x);
  55. #else
  56. #define ReadInt16(f, p)        ReadBytes((f), (p), 2L)
  57. #define ReadInt32(f, p)        ReadBytes((f), (p), 4L)
  58. #define ReadFloat32(f, p)    ReadBytes((f), (p), 4L)
  59. #define WriteInt16(f, p)    WriteBytes((f), (p), 2L)
  60. #define WriteInt32(f, p)    WriteBytes((f), (p), 4L)
  61. #define WriteFloat32(f, p)    WriteBytes((f), (p), 4L)
  62. #define SwapInt16(x)        (x)
  63. #define SwapInt32(x)        (x)
  64. #define SwapFloat32(x)        (x)
  65. #endif /* FAT_ENDIAN */
  66.  
  67. #define FROMDISK    -1
  68. struct PACKDirectory
  69. {
  70.    char   name[56];             /* name of file */
  71.    UInt32 offset;               /* offset to start of data */
  72.    UInt32 size;                 /* byte size of data */
  73. };
  74. typedef struct PACKDirectory *PACKDirPtr;
  75.  
  76. typedef struct DirListStruct
  77. {
  78.     char                    dirname[1024];
  79.     int                        from;
  80.     struct    DirListStruct    *next;
  81. } DIRLIST;
  82.  
  83. typedef struct FileListStruct
  84. {
  85.     char                    filename[1024];
  86.     UInt32                    offset;
  87.     UInt32                    size;
  88.     struct    FileListStruct    *next;
  89. } FILELIST;
  90.  
  91. typedef struct DirStruct
  92. {
  93.     char                name[1024];
  94.     FILELIST            *files;
  95.     struct DirStruct    *next;
  96. } DIRECTORY;
  97.  
  98.  
  99. extern int m_nPAKIndex;
  100. extern FILE* pakfile[16];
  101. extern boolean pakopen;
  102. extern DIRECTORY    *paktextures;
  103.  
  104. void    ClearFileList                (FILELIST **);
  105. void    ClearDirList                (DIRLIST **);
  106. boolean        GetPackFileList                (FILELIST **, char *);
  107. boolean        GetPackTextureDirs            (DIRLIST **);
  108. boolean    AddToDirListAlphabetized    (DIRLIST **, char *, int);
  109. boolean    AddToFileListAlphabetized    (FILELIST **t, char *, UInt32, UInt32, boolean);
  110. boolean    PakLoadFile                    (const char *, void **);
  111. void    OpenPakFile                    (const char *);
  112. void    ClosePakFile                (void);
  113. int PakLoadAnyFile(const char *filename, void **bufferptr);
  114. void WINAPI InitPakFile(const char * pBasePath, const char *pName);
  115.  
  116. #ifdef __cplusplus
  117. }
  118. #endif
  119.  
  120. #endif
  121.